//
//  MRClient.h
//  BonjourClient
//
//  Created by Magic on 12/8/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>


@class MRClient;

@protocol MRClientDelegate <NSObject>

- (void)didReadData:(NSData *)data withTag:(long)tag;
- (void)didConnectToServer;
- (void)shouldTimeoutRead;

@end


@interface MRClient : NSObject <NSNetServiceBrowserDelegate,NSNetServiceDelegate>

@property (nonatomic,assign) id<MRClientDelegate> delegate;
@property (readonly) BOOL connected;

+ (MRClient *)sharedClient;
- (void)searchForServicesOfType:(NSString *)type;
- (BOOL)connectToServiceWithName:(NSString *)name;

- (void)writeData:(NSData *)data tag:(NSInteger)tag;

- (void)readDataToLength:(NSUInteger)length tag:(long)tag;
- (void)readDataToLength:(NSUInteger)length tag:(long)tag timeout:(NSTimeInterval)timeout;

@end
